#include "ResultAdder.h"
#include "AssetPool.h"
#include "..\core\src\AssetManager.h"
#include "../core/src/container/Result.h"

namespace Xps
{
	ResultAdder::ResultAdder(QWidget* parent) : AssetAdder(parent, "Add Result", ":/rs/images/result.png")
	{
		//head = setupHeader("Add Question2", );
		content = setupContent();
	}

	ResultAdder::~ResultAdder(void)
	{
	}

	QWidget* ResultAdder::setupContent()
	{	
		text = new QLineEdit();

		QGridLayout* content_layout = new QGridLayout();
		content->setLayout(content_layout);
		content->setStyleSheet("background: white; color: black;");
		content_layout->addWidget(text, 1, 0);
		content_layout->addWidget(new QLabel("Enter the Name of the Result you wish to create."),0, 0);
		text->setFocus(Qt::FocusReason::TabFocusReason);

		return content;
	}


	void ResultAdder::accept()
	{
		XpsAssets::AssetManager* am = ((Xps::AssetPool*) parent())->am;
		int id = am->createResult();
		XpsAssets::Result* r = am->getResult(id);
		r->setName(text->text());
		QDialog::accept();
	}
}
